<?php echo $this->load->view('include/header'); ?>
<h1>Welcome to thesis management</h1>

<form method="post" action= 'site/search'>
<label for="thesis_name">Search by</label>

<select name="attribute">
<option value="name">Name</option>
<option value="id">Id</option>
<option value="type">Type</option>
<option value="teacher">Teacher name</option>
</select>

<input type="text" name="attribute_name" />
<input type="submit" name="submit" value="Search" />
</form>
<?php 
	echo "<table border='1'>
	<tr>
	<th>Topic ID</th>
	<th>Name</th>
	<th>Supervisior</th>
	<th>Type</th>
	<th>Quantity</th>
	<th>Available</th>
	</tr>";
	foreach($rows as $r){
		if ($r){
			echo "<tr>";
			echo '<td align="center">'.$r->thesis_id.'</td>';
			echo '<td align="center">'.anchor('thesis/viewtopic/'.$r->thesis_id,$r->name).'</td>';
			echo '<td align="center">'.$r->firstname.' '.$r->lastname.'</td>';
			echo '<td align="center">'.$r->thesisType.'</td>';
			echo '<td align="center">'.'<p>'.$r->quantity_students.'</p>'.'</td>';
			echo '<td align="center">'.'<p>'.($r->quantity_students - $r->accepted).'</p>'.'</td>';
			echo "</tr>";	
		}
		else 	
			echo '<p>'."No topic is avaiable".'</p>';
	}
	echo "</table>";
?>
<?php echo $this->load->view('include/footer'); ?>